package com.star.spring.my.service.controller;

import com.star.spring.my.service.service.email.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName EmailCOntroller
 * @Author star
 * @Date 2024/3/1 16:21
 */

@RestController
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private MailService mailService;

    private String TO = "3303141365@qq.com";

    private String SUBJECT = "测试SpringBoot发送邮件之发送带图片的邮件";

    private String CONTENT = "接收了邮件中的附件";

    private String HTML = "<h1>测试邮件发送html</h1>";

    private String HTML1 = "<img src='C:/Users/abc/Pictures/1694668957060.jpg'>测试邮件发送html</img>";

    private String filePath="C:/Users/abc/Pictures/1694668957060.jpg";


    @PostMapping
    public String sendEmail(){

        System.out.println("start send email");
        // 测试邮件发送简单文本
        mailService.sendSimpleMail(TO, SUBJECT, CONTENT);

        // 测试邮件发送HTML
        mailService.sendHtmlMail(TO,SUBJECT,HTML);

        // 测试邮件发送文件
//        mailService.sendAttachmentMail(TO,SUBJECT,CONTENT,filePath);
//
//        // 测试发带图片的邮件
//        mailService.sendInlineResourceMail(TO,SUBJECT,HTML1,filePath,"1234");

        return "success";
    }
}
